/**
 * 系统信息相关方法
 */
import {
  toast
} from '@/utils/toast.js'
// 系统信息
let systemInfo = {}
try {
  systemInfo = uni.getSystemInfoSync()
} catch (e) {
  toast.error('系统信息获取失败')
}
// #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
// 胶囊信息
const menuButtonInfo = uni.getMenuButtonBoundingClientRect() || {}
// #endif


// 状态栏高度
const statusBarHeight = systemInfo.statusBarHeight;
// #ifdef  MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
// 导航栏高度(不包括状态栏)
const navigationHeight = menuButtonInfo.height + (menuButtonInfo.top - statusBarHeight) * 2;
// #endif

// #ifdef  MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
// nav bar 高度(包含状态栏)
const navBarHeight = navigationHeight + statusBarHeight
// #endif

// #ifdef  MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
// 胶囊的左边框到设备屏幕右边的距离
const menuPlaceWidth = systemInfo.windowWidth - menuButtonInfo.left
// #endif


export {
  systemInfo,
  statusBarHeight,
  // #ifdef  MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
  navigationHeight,
  navBarHeight,
  menuButtonInfo,
  menuPlaceWidth
  // #endif
}
